/**
 * 
 */
package org.statewalker.fsm.providers;

import java.util.HashMap;
import java.util.Map;

/**
 * @author kotelnikov
 */
public class FsmTransitionsRegistry<SK, EK>
    implements
    IFsmTransitionsRegistry<SK, EK> {

    private Map<SK, IFsmTransitions<SK, EK>> fTransitions = new HashMap<SK, IFsmTransitions<SK, EK>>();

    /**
     * 
     */
    public FsmTransitionsRegistry() {
        super();
    }

    /**
     * @see org.statewalker.fsm.providers.IFsmTransitionsRegistry#getTransitions(java.lang.Object)
     */
    public synchronized IFsmTransitions<SK, EK> getTransitions(SK stateKey) {
        return fTransitions.get(stateKey);
    }

    /**
     * @see org.statewalker.fsm.providers.IFsmTransitionsRegistry#registerTransitions(java.lang.Object,
     *      org.statewalker.fsm.providers.IFsmTransitions)
     */
    public synchronized void registerTransitions(
        SK stateKey,
        IFsmTransitions<SK, EK> transitions) {
        fTransitions.put(stateKey, transitions);
    }

    /**
     * @see org.statewalker.fsm.providers.IFsmTransitionsRegistry#removeTransitions(java.lang.Object,
     *      IFsmTransitions)
     */
    public synchronized void removeTransitions(
        SK stateKey,
        IFsmTransitions<SK, EK> transitions) {
        fTransitions.remove(stateKey);
    }
}
